package com.ming.redis.service.redisListener;

import com.alibaba.fastjson.JSONObject;
import com.ming.redis.model.TestPojo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.context.annotation.Configuration;

import java.util.List;


/**
 * @Auther: tangC
 * @Date: 2020/7/6 11:00
 * @Description:
 */
@Configuration
@Slf4j
public class RedisMessageTestListener {

    public void test(String jsonMsg){
        log.info("开始消费");
        try {
            log.info(jsonMsg+"test1");
        }catch (Exception e){
            e.printStackTrace();
            log.error("[消费REDIS消息队列phone数据成功.]");
        }
    }

    public void test2(String jsonMsg){
        log.info("开始消费");
        try {
            log.info(jsonMsg+"test2");
        }catch (Exception e){
            e.printStackTrace();
            log.error("[消费REDIS消息队列phone数据成功.]");
        }
    }


    public void receiveMessage(List<TestPojo> pojos){
//        Jackson2JsonRedisSerializer seria = new Jackson2JsonRedisSerializer(ResultData.class);
//        ObjectMapper objectMapper = new ObjectMapper();
//        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
//        objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
//        seria.setObjectMapper(objectMapper);
//        ResultData resultData = (ResultData)seria.deserialize(msg.getBytes());

        for (TestPojo testPojo : pojos) {
            System.out.println(testPojo.getA());
            System.out.println(testPojo.getB());
        }
//        TestPojo testPojo = JSON.parseObject(msg,TestPojo.class);

        System.out.println(pojos);
    }
}
